import React from "react";
import Son1 from "./Son1";
// 祖先元素给子元素传值
// 1. 调用 React.createContext() 方法获取 Provider, Consumer 两个组件, 并将 Consumer 组件导出
const { Provider, Consumer } = React.createContext()
export const Con = Consumer

export default class Father extends React.Component {
  render() {
    return (
      // 2. 用 Provider 组件作为根节点,把要传递的值绑定到 value 属性上
      <Provider value={100}>
        <div>
          father
          <Son1 name="zs" age={15}>
              <div>before</div>
              <div>after</div>
          </Son1>
        </div>
      </Provider>
      
    );
  }
}